import { createRouter, createWebHistory } from "vue-router";
import routes from "./routes"
// 创建路由实例
const router = createRouter({
    history: createWebHistory(),
    linkExactActiveClass: "exact-active",
    linkActiveClass: "active",
    routes,
});

router.beforeEach((to, from, next) => {
    // 如果没有teken，且访问的是非登录页,拦截到登录，其他情况正常放行
    if (!sessionStorage.getItem("token") && to.path !== '/') {
        next("/")
    } else {
        next()
    }
})
export default router